package cn.fan;

import cn.fan.feign.clients.UserClient;
import cn.fan.feign.config.FeignClientConfiguration;
import com.alibaba.cloud.nacos.ribbon.NacosRule;
import com.netflix.loadbalancer.IRule;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableCaching
@EnableFeignClients(clients = {UserClient.class},defaultConfiguration = FeignClientConfiguration.class)
public class FundServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(FundServiceApplication.class, args);

//        ConfigurableApplicationContext run = SpringApplication.run(FundServiceApplication.class, args);
//
//        System.out.println("--------------------------------------");
//        String[] beans = run.getBeanDefinitionNames();
//        for(String bean:beans){
//            System.out.println(bean);
//        }
//        System.out.println("--------------------------------------");

    }

    @Bean
//    @LoadBalanced
    RestTemplate restTemplate(){
        return new RestTemplate();
    }

//    @Bean   //设置负载均衡策略，为随机策略
//    public IRule randomRule(){
//        return new NacosRule();
//    }
}
